<?php
class SingleWidget extends BaseWidget{
	/**
	 * 显示前获取需要显示的数据
	 */
	public function get_data(){
		$mod = new ArticleModel();
		$article = null;
		if(isset($this->config['id'])){
			$article = $mod->get_by_key_site_limit($this->config['id']);
		}elseif(isset($this->config['alias'])){
			$article = $mod->get_by_attrs(array('site_id'=>SITE_ID, 'alias'=>$this->config['alias']));
		}
		$cate = Article_cateModel::get_cate_by_key($article['cate']);
		if($cate!==null){
			$article['cate_name'] = $cate['name'];
			$article['cate'] = $cate;
			if(isset($article['alias']) && trim($article['alias'])!==''){
				$article['url'] = $cate['path'] . '/' . $article['alias']. '.html';
			}else{
				$article['url'] = $cate['path'] . '/' . $article['_id'] . '.html';
			}
		}
		return array('article' => $article);
	}
}

?>